
/** @file basic_sector_decomposition.h
 *
 * Interface to basic_sector_decomposition
 *
 */

/*
 *  Copyright (C) 2007 Stefan Weinzierl
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __SECTOR_DECOMPOSITION_BASIC_SECTOR_DECOMPOSITION_H__
#define __SECTOR_DECOMPOSITION_BASIC_SECTOR_DECOMPOSITION_H__

#include <vector>

#include "integrand.h"
#include "monte_carlo.h"

namespace sector_decomposition {

  monte_carlo_result do_sector_decomposition(const integration_data & global_data,
					     const integrand & integrand_in, 
					     const monte_carlo_parameters & mc_parameters,
					     int verbose_level = 0);

  monte_carlo_result do_sector_decomposition_simplex(const integration_data & global_data,
						     const integrand & integrand_in, 
						     const monte_carlo_parameters & mc_parameters,
						     int verbose_level = 0);

  monte_carlo_result do_sector_decomposition_cube(const integration_data & global_data,
						  const integrand & integrand_in, 
						  const monte_carlo_parameters & mc_parameters,
						  int verbose_level = 0);

  monte_carlo_result do_sector_decomposition_cube_coordinate_subspace(const integration_data & global_data,
								      const integrand & integrand_in, 
								      const monte_carlo_parameters & mc_parameters,
								      int verbose_level = 0);

  /**
   *
   * A function object with the implementation of the algorithm
   * for sector decomposition.
   *
   * This class is called from the entry point do_sector_decomposition.
   * The parameters are as in the function do_sector_decomposition.
   *
   * The main method of this class is the operator().
   *
   */
  class basic_sector_decomposition {

      // member functions
    public:
    monte_carlo_result operator() (const integration_data & global_data,
				   const integrand & integrand_in, 
				   const monte_carlo_parameters & mc_parameters,
				   const int & verbose_level);

    monte_carlo_result operator() (const integration_data & global_data,
				   const integrand & integrand_in, 
				   const monte_carlo_parameters & mc_parameters,
				   const int & integration_domain,
				   const int & verbose_level);

    void generate_homogenous_polynomials(const integration_data & global_data, 
					 const integrand & integrand_in, integrand & integrand_out);

    void generate_primary_sectors(const integration_data & global_data, 
				  const integrand & integrand_in, std::vector<integrand> & lst_integrand_out);

    void generate_primary_sectors_cube(const integration_data & global_data, 
				       const integrand & integrand_in, std::vector<integrand> & lst_integrand_out);

    void iterate_sector_decomposition(const integration_data & global_data, 
				      std::vector<integrand> & lst_integrand_in, std::vector<integrand> & lst_integrand_out);

    void strategy_A(const integration_data & global_data, 
		    std::vector<integrand> & lst_integrand_in, std::vector<integrand> & lst_integrand_out);

    void strategy_B(const integration_data & global_data, 
		    std::vector<integrand> & lst_integrand_in, std::vector<integrand> & lst_integrand_out);

    void strategy_C(const integration_data & global_data, 
		    std::vector<integrand> & lst_integrand_in, std::vector<integrand> & lst_integrand_out);

    void strategy_X(const integration_data & global_data, 
		    std::vector<integrand> & lst_integrand_in, std::vector<integrand> & lst_integrand_out);

    void strategy_Y(const integration_data & global_data, 
		    std::vector<integrand> & lst_integrand_in, std::vector<integrand> & lst_integrand_out);

    void generate_subtraction_terms(const integration_data & global_data, 
				    std::vector<integrand> & lst_integrand_in, std::vector<GiNaC::ex> & lst_integrand_out);

    void expand_in_epsilon(const integration_data & global_data, 
			   std::vector<GiNaC::ex> & lst_integrand_in, GiNaC::ex & res_out, std::vector<GiNaC::ex> & res_out2);

    void expand_in_epsilon(const integration_data & global_data,
			   std::vector<GiNaC::ex> & lst_integrand_in, GiNaC::ex & res_out);

    void numerical_integration(const integration_data & global_data, const monte_carlo_parameters & mc_parameters, GiNaC::ex res_in, monte_carlo_result & res_out, int verbose_level = 0);

  };

} // namespace sector_decomposition

#endif // ndef __SECTOR_DECOMPOSITION_BASIC_SECTOR_DECOMPOSITION_H__

